package com.gamex.findit.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.dao.MemberMapper;
import com.gamex.findit.model.Member;
import com.gamex.findit.service.MemberService;

/**
 * 회원정보 서비스
 * @author james
 *
 */
@Service
public class MemberServiceImpl implements MemberService{

	private static final Logger logger = LoggerFactory.getLogger(MemberServiceImpl.class);
	
	@Autowired MemberMapper memberMapper;
	
	@Override
	public List<Member> getMember(Member member) throws Exception{
		
		List<Member> members = null;
		try {
			members = memberMapper.selectMember(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
		return members;
	}

	@Override
	public Member getMemberView(String userId) throws Exception {
		Member result = null;
		try {
			result = memberMapper.selectMemberView(userId);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public void updateMember(Member member) throws Exception {
		try {
			memberMapper.updateMember(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	@Override
	public void deleteMember(Member member) throws Exception {
		try {
			memberMapper.deleteMember(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	@Override
	public int insertMember(Member member) throws Exception {
		int result = 0 ;
		try {
			result = memberMapper.insertMember(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public int getMemberCount(Member member) throws Exception {
		int result = 0;
		try {
			result = memberMapper.selectMemberCount(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public void updateMemberNumeric(Member member) throws Exception{
		try {
			memberMapper.updateMemberNumeric(member);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

}
